<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');

// ------------------------------------------------------------------------

function thumb($src, $w, $h){
	if(!$w){
		$cond = "h=$h&zc=1";
	}elseif(!$h){
		$cond = "w=$w&zc=1";
	}else{
		$cond = "w=$w&h=$h&zc=1";
	}
	return site_url()."uploads/timthumb.php?src=$src&$cond";
}

function fileTarget($user_id, $file){
	return site_url()."uploads/default/users/$user_id/$file";
}

function loader_image($ext=""){
	return "<img $ext src='".site_url()."addons/default/themes/sbx/css/images/ajax-loader.gif"."' />";
}

function getImagesFromArticle($article, $mode="ONE"){
	$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $article, $matches);
	if($mode == "ONE"){
		return $matches[1][0];
	}else{
		return $matches[1];
	}	
}